package com.ly.consumer.thread.threadCommonMethod;
//线程让步
class YieldThread1 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("A线程");
            //让A线程给B线程让出cpu的使用权 A线程就回到了可执行状态 等待cpu的调度
            Thread.yield();
        }
    }
}
class YieldThread2 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("B线程");
        }
    }
}
public class MyYield {
    public static void main(String[] args) {
        new Thread(new YieldThread1()).start();
        new Thread(new YieldThread2()).start();
    }
}
